home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CBASE102.ARJ / FDCSET.C < prev    next >
Text File  |  1991-09-23  |  2KB  |  73 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)fdcset.c    1.5 - 91/09/23" */
  5.  
  6. #include <ansi.h>
  7.  
  8. /* ansi headers */
  9. #include <errno.h>
  10. #ifdef AC_STRING
  11. #include <string.h>
  12. #endif
  13.  
  14. /* system headers */
  15. #include <dos.h>
  16.  
  17. extern int _doserrno;
  18.  
  19. /*man---------------------------------------------------------------------------
  20. NAME
  21.      fdcset - set file descriptor count
  22.  
  23. SYNOPSIS
  24.      int fdcset(fdc)
  25.      int fdc;
  26.  
  27. DESCRIPTION
  28.      The fdcset function sets the file descriptor count of the calling
  29.      process to fdc.  fdc can be no more than the number of entries in
  30.      the system file table set by FILES= in config.sys.
  31.  
  32.      This function is for DOS only, and requires version 3.3 or higher.
  33.  
  34.      fdcset will fail if one or more of the following is true:
  35.  
  36.      [EINVAL]       fdc is less than 1.
  37.      [ENOMEM]       Not enough memory for expanded file descriptor
  38.                     table.
  39.  
  40. DIAGNOSTICS
  41.      Upon successful completion, a value of 0 is returned.  Otherwise,
  42.      a value of -1 is returned, and errno set to indicate the error.
  43.  
  44. ------------------------------------------------------------------------------*/
  45. #ifdef AC_PROTO
  46. int fdcset(int fdc)
  47. #else
  48. int fdcset(fdc)
  49. #endif
  50. {
  51.     union REGS    regs;        /* registers */
  52.  
  53.     /* validate arguments */
  54.     if (fdc < 1) {
  55.         errno = EINVAL;
  56.         return -1;
  57.     }
  58.  
  59.     /* call DOS function 67h to set fildes count */
  60.     memset(®s, 0, sizeof(regs));
  61.     regs.h.ah = 0x67;
  62.     regs.x.bx = fdc;
  63.     (void)intdos(®s, ®s);
  64.     if (regs.x.cflag) {
  65.         if (_doserrno == ENOMEM) {
  66.             errno = ENOMEM;
  67.         }
  68.         return -1;
  69.     }
  70.  
  71.     return 0;
  72. }
  73.